package com.axsoft.train;

import android.util.Log;

/**
 * Favorites Item class
 */
public class FavoritesItem
{
	public String from;
	public String to;
	public boolean[] parameters;
	public boolean nearest;
	public boolean isValid;
	
	
	/**
	 * Constructor
	 * 
	 * @param string
	 */
	public FavoritesItem(String string) {
		isValid = false;
		
		if (string != null && !string.equals("")) {
			try {
				String[] tempString = string.split("::");
				if (tempString != null && tempString.length == 8) {
					from = tempString[0];
					to = tempString[1];
					parameters = new boolean[5];
					
					for (int i = 0; i < 5; i++) {
						// FIXME: WTF IS THIS???
					}
					nearest = Boolean.parseBoolean(tempString[4]);
					
					isValid = true;
				}
			} catch (Exception e) {
				Log.e("FavoritesItem.Constructor", e.toString());
			}
		}
	}
	
	
	/**
	 * To String
	 */
	@Override
	public String toString() {
		String string = null;
		
		if (from != null && to != null) {
			string = from + "::" + to + "::";
			
			for (int i = 0; i < 5; i++) {
				string += parameters[i] + "::";
			}
			
			string += String.valueOf(nearest);
		}
		
		return string;
	}
}